<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>



<script type="text/javascript">

var  adres= document.location.href;
    function Printing(parentDiv, childDiv , parentDiv2 , childDiv2) 
    {
    	var czesc = adres.split('index.jsp?add=');
    	var adres2=czesc[0]+czesc[1]+".jsp";   	
        var mywindow = window.open(adres2, 'my div', 'height=500,width=300');
        jQuery(mywindow).bind("load",function(){

        	   if (childDiv == parentDiv) {
                
              }
              else if (mywindow.document.getElementById(childDiv)) {     
                   var child = mywindow.document.getElementById(childDiv);
                   var parent = mywindow.document.getElementById(parentDiv);
                   parent.removeChild(child);
              }
              else {
                
                   return false;
              }
        	   
        	   if (childDiv2 == parentDiv2) {
                   
               }
               else if (mywindow.document.getElementById(childDiv2)) {     
                    var child = mywindow.document.getElementById(childDiv2);
                    var parent = mywindow.document.getElementById(parentDiv2);
                    parent.removeChild(child);
               }
               else {
                 
                    return false;
               }
        	   
        	   
        	
        	mywindow.print(); 
        	mywindow.close(); });
 
        return true;
    }
</script>



<link href="style2.css" rel="stylesheet" type="text/css" />

<f:subview id="statistics">
	<a4j:loadBundle var="msg" basename="messages_#{localManager.local}"></a4j:loadBundle>
	<h:form style="overflow:auto">

		<div id="non-printable">
			<div id="test2">
				<tr:document>
					<tr:chart id="char1" tooltipsVisible="true" partialTriggers="guzik"
						legendPosition="top" value="#{pracownikStatisticsManager}"
						type="#{pracownikStatisticsManager.selectedTypWykresu}"
						animationDuration="2000"
						perspective="#{pracownikStatisticsManager.perspektywa}"
						shortDesc="wykres 1 " inlineStyle="width:1000px; height: 500px;" />
				</tr:document>
			
		<a4j:commandButton styleClass="RFbutton"
			value="#{msg['kurier.konfiguruj']}"
			oncomplete="#{rich:component('config')}.show()">
		</a4j:commandButton>
		<a href="../Faces/index.jsp?add=/pracownik/statistics"
			class="RFbutton"> <h:outputText id="konfig"
				value="#{msg['kurier.generuj']}"></h:outputText> </a>

</div>
		</div>
		<br></br>
		<a4j:region id="regionData">

			<div id="test">
				<rich:dataTable id="dataList"
					value="#{pracownikStatisticsManager.dataList}" var="dataItem"
					reRender="ds" onRowContextMenu="row=this; alert(this);"
					onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
					onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
					cellpadding="0" cellspacing="0" border="0" rows="20">

					<f:facet name="header">
						<h:outputText value="#{pracownikStatisticsManager.tytul}" />
					</f:facet>

					<rich:column width="25" sortBy="#{dataItem.label}">
						<f:facet name="header">
							<h:outputText value="#{msg['kurier.nazwa.obiektu']}" />
						</f:facet>
						<h:outputText value="#{dataItem.label}" />
					</rich:column>

					<rich:column sortBy="#{dataItem.data}">
						<f:facet name="header">
							<h:outputText value="#{msg['kurier.data']}" />
						</f:facet>
						<h:outputText value="#{dataItem.data}" />
					</rich:column>

					<rich:column sortBy="#{dataItem.positionY}">
						<f:facet name="header">
							<h:outputText value="#{msg['kurier.wartosc']}" />
						</f:facet>
						<h:outputText value="#{dataItem.positionY}" />
					</rich:column>


					<f:facet name="footer">
						<rich:datascroller id="ds" align="center" for="dataList"
							maxPages="20" />
					</f:facet>
				</rich:dataTable>
				<rich:messages id="mymessages" globalOnly="true" style="color:red" />

				<div id="non-drukuj">
					<h:commandButton id="drukujButton"
						onclick="Printing('non-printable','test2', 'test','non-drukuj'); return false;"
						styleClass="RFbutton" value="Drukuj"></h:commandButton>
				</div>
			</div>


		</a4j:region>


	</h:form>

	<rich:modalPanel id="config" domElementAttachment="parent"
		autosized="true" width="500" height="350">
		<f:facet name="header">
			<h:outputText id="addLabel" value="#{msg['kurier.konfiguruj']}"></h:outputText>
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
					<h:graphicImage value="/images/close2.png" styleClass="hidelink"
						id="hidelink" />
					<rich:componentControl for="config" attachTo="hidelink"
						operation="hide" event="onclick" />
				</h:panelGroup>
		</f:facet>
		<h:form>
			<a4j:outputPanel>
				<h:panelGrid columns="2" border="0">
					<h:outputLabel for="typWykresu"
						value="#{msg['kurier.typ.wykresu']}:" />
					<h:selectOneMenu id="typWykresu"
						value="#{pracownikStatisticsManager.selectedTypWykresu}"
						immediate="true">
						<f:selectItems value="#{pracownikStatisticsManager.typWykresu}" />
						<a4j:support event="onchange"
							action="#{pracownikStatisticsManager.changeTyp}"
							reRender="kurierzy">
						</a4j:support>
					</h:selectOneMenu>


					<h:outputLabel for="perspektywa"
						value="#{msg['kurier.perspektywa']}:" />
					<h:selectBooleanCheckbox id="perspektywa"
						value="#{pracownikStatisticsManager.perspektywa}">
						<h:outputText value="2.5D"></h:outputText>
					</h:selectBooleanCheckbox>


					<h:outputLabel for="typy" value="#{msg['kurier.statystyka']}:" />
					<h:column>
					<h:selectOneMenu id="typy"
						value="#{pracownikStatisticsManager.selectedTyp}" immediate="true">
						<f:selectItems value="#{pracownikStatisticsManager.typy}" />
						<a4j:support event="onchange"
							action="#{pracownikStatisticsManager.changeTyp}"
							reRender="kurierzy, oddzialy ">
						</a4j:support>
					</h:selectOneMenu>
					<span style="white-space: nowrap">
						 <h:outputText style="color:red"	value="#{msg['kurier.tip']}"></h:outputText> </span>
						</h:column>

					<h:outputLabel for="kurierzy" value="#{msg['kurier.dane']}:" />
					<h:column>
						<h:panelGrid columns="2">
							<h:column>
								<h:selectManyListbox id="kurierzy"
									value="#{pracownikStatisticsManager.selectedKurier}"
									disabled="#{pracownikStatisticsManager.disabledKurier}"
									immediate="true">
									<f:selectItems
										value="#{pracownikStatisticsManager.listaKurierow}" />
									
								</h:selectManyListbox>
							</h:column>
							<h:column>
								<h:selectManyListbox id="oddzialy"
									value="#{pracownikStatisticsManager.selectedOddzial}"
									immediate="true"
									disabled="#{pracownikStatisticsManager.disabledOddzialy}">
									<f:selectItems
										value="#{pracownikStatisticsManager.listaOdzialow}" />
									<a4j:support event="onchange" ajaxSingle="true">
									</a4j:support>
								</h:selectManyListbox>
							</h:column>
						</h:panelGrid>
					</h:column>
					<h:outputLabel for="od" value="#{msg['kurier.od']}:" />
					<rich:calendar id="od" value="#{pracownikStatisticsManager.dataOd}"
						ajaxSingle="true" immediate="true"
						direction="top-right"
						locale="#{pracownikStatisticsManager.calendar.locale}"
						popup="#{pracownikStatisticsManager.calendar.popup}"
						datePattern="#{pracownikStatisticsManager.calendar.pattern}"
						cellWidth="24px" cellHeight="22px" style="width:200px" />

					<h:outputLabel for="do" value="#{msg['kurier.do']}:" />
					<rich:calendar id="do" value="#{pracownikStatisticsManager.dataDo}"
						ajaxSingle="true" immediate="true"
						direction="top-right"
						locale="#{pracownikStatisticsManager.calendar.locale}"
						popup="#{pracownikStatisticsManager.calendar.popup}"
						datePattern="#{pracownikStatisticsManager.calendar.pattern}"
						cellWidth="24px" cellHeight="22px" style="width:200px" />

					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.zapisz']}"
						action="#{pracownikStatisticsManager.save}"
						reRender="dataList"
						oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('config')}.hide();}" />
					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.anuluj']}"
						onclick="#{rich:component('config')}.hide(); return false;" />
				</h:panelGrid>
			</a4j:outputPanel>
		</h:form>
	</rich:modalPanel>
</f:subview>
